#!/usr/bin/python3.5

# -*- coding: utf-8 -*-


def threeSum(nums):
    if len(nums)<3:
        return []

    else:
        nums.sort()

        if nums[0]>0:
            return []

        result=[]
        i =0
        while i <len(nums)-2:
             a= i+1
             b = len(nums) - 1
             while a < b:
                 sums = nums[a]+nums[b]+ nums[i]
                 if  sums==0:
                     result.append([nums[i],nums[a],nums[b]])
                     a += 1
                     while a < b and nums[a]==nums[a-1]:
                         a+=1
                 elif sums >0:
                      b-=1
                 else:
                      a+=1
             i += 1
             while i< len(nums)-2 and nums[i]==nums[i-1]:
                   i+=1

    return result









nums = []


print(threeSum(nums))